<html>
<head><meta charset="utf-8"><title>-Z unpretty=everybody_loops does not behave as expected · t-compiler/help · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/index.html">t-compiler/help</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/-Z.20unpretty.3Deverybody_loops.20does.20not.20behave.20as.20expected.html">-Z unpretty=everybody_loops does not behave as expected</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="201441326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/-Z%20unpretty%3Deverybody_loops%20does%20not%20behave%20as%20expected/near/201441326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/-Z.20unpretty.3Deverybody_loops.20does.20not.20behave.20as.20expected.html#201441326">(Jun 19 2020 at 21:20)</a>:</h4>
<p>I'm looking at <code>ReplaceBodyInLoop</code> for <a href="https://github.com/rust-lang/rust/pull/73103#issuecomment-646339691">https://github.com/rust-lang/rust/pull/73103#issuecomment-646339691</a>. From my understanding, this replaces function bodies with <code>loop {}</code> so rustc doesn't have to do item-bodies checking. However, I'm not seeing this in the debug output:</p>
<div class="codehilite"><pre><span></span><code><span class="cp">$</span><span class="w"> </span><span class="n">rustc</span><span class="w"> </span><span class="o">+</span><span class="n">nightly</span><span class="w"> </span><span class="kr">priv</span><span class="o">-</span><span class="k">in</span><span class="o">-</span><span class="k">pub</span><span class="p">.</span><span class="n">rs</span><span class="w">  </span><span class="o">-</span><span class="n">Z</span><span class="w"> </span><span class="n">unpretty</span><span class="o">=</span><span class="n">everybody_loops</span><span class="w"></span>
<span class="cp">#![no_std]</span><span class="w"></span>

<span class="sd">/// See also [`g()`][crate::g] and [`h()`]</span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">f</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>

<span class="k">fn</span> <span class="nf">g</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="k">pub</span><span class="w"> </span><span class="k">fn</span> <span class="nf">h</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="mi">1</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="mi">2</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>Am I misunderstanding what this does? Why isn't <code>1 + 2;</code> replaced with <code>loop {}</code>?</p>



<a name="201442823"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/-Z%20unpretty%3Deverybody_loops%20does%20not%20behave%20as%20expected/near/201442823" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/-Z.20unpretty.3Deverybody_loops.20does.20not.20behave.20as.20expected.html#201442823">(Jun 19 2020 at 21:37)</a>:</h4>
<p>I added some debug logging and it looks like <code>ReplaceBodyInLoop</code> just isn't being run at <em>all</em>. It must have broken silently at some point.</p>



<a name="201451395"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/-Z%20unpretty%3Deverybody_loops%20does%20not%20behave%20as%20expected/near/201451395" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/-Z.20unpretty.3Deverybody_loops.20does.20not.20behave.20as.20expected.html#201451395">(Jun 19 2020 at 23:50)</a>:</h4>
<p>I think I have a fix, it needs to return <code>true</code> from <code>needs_ast_map</code>.</p>



<a name="201452563"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/182449-t-compiler/help/topic/-Z%20unpretty%3Deverybody_loops%20does%20not%20behave%20as%20expected/near/201452563" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/182449-t-compiler/help/topic/-Z.20unpretty.3Deverybody_loops.20does.20not.20behave.20as.20expected.html#201452563">(Jun 20 2020 at 00:13)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/73523">https://github.com/rust-lang/rust/pull/73523</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>